<template>
  <div class="app-header-sticky" :class="{ show: score >= 78 }">
    <div class="container">
      <RouterLink class="logo" to="/"></RouterLink>
      <AppHeaderNav></AppHeaderNav>
      <div class="right">
        <RouterLink class="" to="/">品牌</RouterLink>
        <RouterLink class="" to="/">专题</RouterLink>
      </div>
    </div>
  </div>
</template>

<script>
import AppHeaderNav from "./app-header-nav.vue";
export default {
  name: "AppHeadeSticky",
  components: {
    AppHeaderNav,
  },
  data() {
    return {
      score: 0,
    };
  },
  methods: {
    handleScroll() {
      const res = document.querySelectorAll("html");
      this.score = res[0].scrollTop;
    },
  },
  mounted() {
    window.addEventListener("scroll", this.handleScroll, true);
  },
  destroyed() {
    window.removeEventListener("scroll", this.handleScroll);
  },
};
</script>

<style lang="less" scoped>
.app-header-sticky {
  width: 100%;
  height: 80px;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 999;
  background-color: #fff;
  border-bottom: 1px solid rgb(66, 64, 64);
  transform: translateY(-100%);
  transition: all 0.3s linear;
  &.show {
    transform: translateY(0);
  }
  .container {
    display: flex;
    align-items: center;
  }
  .logo {
    width: 200px;
    height: 80px;
    background: url("../assets/images/logo.png") no-repeat right 2px;
    background-size: 160px auto;
  }
  .right {
    width: 220px;
    display: flex;
    text-align: center;
    padding-left: 40px;
    border-left: 2px solid @xtxColor;
    a {
      width: 38px;
      font-style: 16px;
      line-height: 1;
      margin-right: 40px;
      &:hover {
        color: @xtxColor;
      }
    }
  }
}
</style>
